﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/**
 * 接口的显示实现，C#语言独有的！
 */
namespace BiliBiliCSharpStudy.clazz.ch29.d04 {
    class IspExample04 {
        public static void Demo() {
            Test1();
        }


        public static void Test2() {
            IKiller killer = new WarmKiller();
            killer.Kill();
            var wk = killer as WarmKiller;
            wk.Love();
            var wk2 = (IGentleman)killer;
            wk2.Love();
        }


        public static void Test1() {
            var wk = new WarmKiller();
            //wk.Kill();
            wk.Love();
            IKiller killer = wk;
            killer.Kill();
        }
    }

    interface IGentleman {
        void Love();
    }
    interface IKiller {
        void Kill();
    }

    class WarmKiller : IGentleman, IKiller {
        //public void Kill() {
        //    Console.WriteLine("Let me kill the enemy...");
        //}

        // 接口的显示实现，C#语言独有的！
        void IKiller.Kill() {
            Console.WriteLine("Let me kill the enemy...");
        }

        public void Love() {
            Console.WriteLine("I will love you for ever...");
        }
    }
}
